<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Title</title>
</head>
<body>

  <!--

    位运算 快捷操作

    判断奇偶  n&1
    求2的n次方 1<<n

   -->

<script>

  // 二分查找算法
  var Arr = [3, 5, 6, 7, 9, 12, 15];
  function binary(find, arr, low, high) {
    if (low <= high) {
      if (arr[low] == find)
        return low;
      if (arr[high] == find)
        return high;
      var mid = Math.ceil((high + low) / 2);
      if (arr[mid] == find) {
        return mid;
      }
      else if (arr[mid] > find) {
        return binary(find, arr, low, mid - 1);
      }
      else {
        return binary(find, arr, mid + 1, high);
      }
    }
    return -1;
  }
  binary(15, Arr, 0, Arr.length - 1);


  // 随机排序
  var list = [1, 2, 3];
  console.log(list.sort(function () {
    return Math.random() - 0.5
  }));

</script>
</body>
</html>
